from typing import Any, Optional

from fastapi.responses import ORJSONResponse

from common.response.response_code import (
    HttpCode,
    CustomErrorCode
)
from common.response.http_response import (
    CustomResponse, CustomContent
)

class Success(CustomResponse):
    def __init__(
        self,
        code: int = HttpCode.HTTP_200,
        msg: Optional[str] = "OK",
        data: Optional[Any] = None,
        **kwargs,
    ):
        content = CustomContent(code=code, msg=msg, data=data).to_dict()
        content.update(kwargs)
        super().__init__(content=content, status_code=code)


class Fail(CustomResponse):
    def __init__(
        self,
        code: int = HttpCode.HTTP_400,
        msg: Optional[str] = None,
        data: Optional[Any] = None,
        **kwargs,
    ):
        content = CustomContent(code=code, msg=msg, data=data).to_dict()
        content.update(kwargs)
        super().__init__(content=content, status_code=code)